package com.smart.community.commons.entity.property;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 物业公司社区关联实体类
 * 
 * 注意：此表不使用软删除，直接使用物理删除
 * 原因：物业公司社区关联表是中间表，不需要软删除功能
 * 设计原则：根据"智慧社区微服务架构总览.md"中的关联表设计原则
 *
 * @author Wu.Liang
 * @version 1.0.0
 * @since 2025-06-29
 */
@Data
@TableName("sc_property_company_community")
@Schema(description = "物业公司社区关联信息")
public class PropertyCompanyCommunity implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "关联ID")
    private Long id;

    @NotNull(message = "物业公司ID不能为空")
    @Min(value = 1, message = "物业公司ID必须大于0")
    @TableField("property_company_id")
    @Schema(description = "物业公司ID", required = true)
    private Long propertyCompanyId;

    @NotNull(message = "社区ID不能为空")
    @Min(value = 1, message = "社区ID必须大于0")
    @TableField("community_id")
    @Schema(description = "社区ID", required = true)
    private Long communityId;

    @Size(max = 100, message = "合同编号长度不能超过100个字符")
    @TableField("contract_no")
    @Schema(description = "合同编号")
    private String contractNo;

    @TableField("service_content")
    @Schema(description = "服务内容")
    private String serviceContent;

    @TableField("service_fee")
    @DecimalMin(value = "0.01", message = "服务费用必须大于0")
    @Digits(integer = 8, fraction = 2, message = "服务费用格式不正确")
    @Schema(description = "服务费用")
    private BigDecimal serviceFee;

    @TableField("service_start_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "服务开始日期")
    private LocalDate serviceStartDate;

    @TableField("service_end_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "服务结束日期")
    private LocalDate serviceEndDate;

    @TableField("status")
    @Min(value = 0, message = "状态值不正确")
    @Max(value = 2, message = "状态值不正确")
    @Schema(description = "状态：0-终止，1-正常，2-暂停")
    private Integer status;

    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建人")
    private Long createBy;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新人")
    private Long updateBy;

    @Version
    @TableField("version")
    @Schema(description = "乐观锁版本号")
    private Integer version;

    @TableField("remark")
    @Schema(description = "备注")
    private String remark;

    /**
     * 状态枚举
     */
    public static class Status {
        /** 终止 */
        public static final Integer TERMINATED = 0;
        /** 正常 */
        public static final Integer NORMAL = 1;
        /** 暂停 */
        public static final Integer SUSPENDED = 2;
    }
} 